<?php 

class ControllerInformationNotice extends Controller {
	public function index() {  
    	$this->language->load('information/notice');

        $this->document->title = $this->language->get('heading_title');  
	
		$this->load->model('catalog/notice');
		
		$this->document->breadcrumbs = array();
		
      	$this->document->breadcrumbs[] = array(
        	'href'      => (HTTP_SERVER . 'index.php?route=common/home'),
        	'text'      => $this->language->get('text_home'),
        	'separator' => FALSE
      	);
		
    	    $this->data['heading_title'] = $this->language->get('heading_title');
      		$this->data['text_title'] = $this->language->get('text_title');
      		$this->data['text_order'] = $this->language->get('text_order');
      		$this->data['text_title'] = $this->language->get('text_title');
      		

			



     		
			
			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/notice.tpl')) {
				$this->template = $this->config->get('config_template') . '/template/information/notice.tpl';
			} else {
				$this->template = 'default/template/information/notice.tpl';
			}
			
			$this->children = array(
				'common/header',
				'common/footer',
				'common/column_left',
				'common/column_right'
			);		

   			if (isset($this->request->get['page'])) {
				$page = $this->request->get['page'];
			} else { 
				$page = 1;
			}	
   			
			$this->data['page'] = $page;

		   


				$pagination = new Pagination();
				$pagination->total =  $this->model_catalog_notice->getNumNotices();
				$pagination->page = $page;
				
				$pagination->limit = 5;
				
				$pagination->url = (HTTP_SERVER . 'index.php?route=information/notice&page={page}');
 				$this->data['pagination'] = $pagination->render();
				
	     	    $this->data['continue'] = (HTTP_SERVER . 'index.php?route=common/home');
				$this->data['notices'] = array();
			   $results = $this->model_catalog_notice->getNotices($page,$pagination->limit);
				foreach ($results as $result) {
				
					$this->data['notices'][] = array(
					'notice_id' => $result['notice_id'],
					'description' => html_entity_decode($result['description']),
					'title'      => $result['title'],
					'sort_order' => $result['sort_order'],
					'href' => HTTP_SERVER . 'index.php?route=information/read_notice&notice_id=' .$result['notice_id'] . '&page='.$page
					
					);
				}
			

			$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));

  	}
}
?>